package com.cn.qgx428.lazydiary.dialog

import android.app.ActionBar
import android.app.Dialog
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import com.cn.qgx428.lazydiary.R
import kotlinx.android.synthetic.main.dialog_img_alert.*

/**
 * Created by qinguanxiong on 2018/1/25.
 */

class ImgAlertDialog: Dialog{

    lateinit var mContext: Context
    lateinit var mainView: View
    lateinit var listener: ()->Unit

    public constructor(context: Context, f: ()->Unit): super(context,R.style.ImgAlertDialog){
        mContext = context
        listener = f
        mainView = LayoutInflater.from(mContext).inflate(R.layout.dialog_img_alert,null)
        setContentView(mainView)
        init();
    }

    private fun init() {
        var lp = window.attributes
        lp.height = ActionBar.LayoutParams.WRAP_CONTENT
        lp.width = ActionBar.LayoutParams.WRAP_CONTENT
        window.attributes = lp

        dialog_imgAlert_cancel.setOnClickListener({dismiss()})
        dialog_imgAlert_commit.setOnClickListener({
            listener()
            dismiss()
        })
    }


}
